home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************************
- * *
- * CursorStuff.c *
- * *
- * ©1995 Douglas Grounds. All Rights Reserved. *
- * *
- * This file contains functions to spin and set the cursor. If the cursor has *
- * already been set as specified, nothing happens, which avoids continuously *
- * flashing the cursor, which is really annoying. *
- * *
- ************************************************************************************/
-
- #include <QuickDraw.h>
- #include <Resources.h>
- #include <ToolUtils.h>
-
- #include "CursorStuff.h"
-
- short gCursID = 0;
- long gCursChange = 0L;
-
- #define kBaseCursorId 256
- #define kMaxCursorId 263
-
- /******************************************************
- * myInitCursor. *
- * *
- * Initializes the cursor. *
- ******************************************************/
-
- void myInitCursor (void)
- {
- if (gCursID != 0)
- InitCursor();
-
- gCursID = 0;
- }
-
- /******************************************************
- * spinCursor. *
- * *
- * Spins the "beach ball" cursor. No initialization *
- * is necessary. This is most effective when called *
- * from within loops. *
- ******************************************************/
-
- void spinCursor (void)
- {
- if ((TickCount() - gCursChange) < 10L)
- return;
-
- if ((gCursID < kBaseCursorId) || (gCursID >= kMaxCursorId))
- gCursID = kBaseCursorId;
-
- mySetCursor(gCursID + 1);
- }
-
- /******************************************************
- * mySetCursor. *
- * *
- * Sets the cursor to the specified cursor ID. If *
- * a color cursor is available, it is used, other- *
- * wise, a black & white cursor is used. *
- ******************************************************/
-
- void mySetCursor (short cursID)
- {
- CCrsrHandle clrCurs;
- CursHandle curs;
-
- if (cursID == gCursID)
- return;
-
- if (cursID == -1)
- {
- if (gCursID != -1)
- {
- gCursID = -1;
- HideCursor();
- }
- }
- else if (gCursID == -1)
- myInitCursor();
-
- clrCurs = NULL;
- clrCurs = GetCCursor(cursID);
- if ((clrCurs == NULL) || (ResError()))
- {
- curs = GetCursor(cursID);
- if ((curs) && (!ResError()))
- {
- SetCursor(*curs);
- gCursID = cursID;
- gCursChange = TickCount();
- }
- }
- else
- {
- SetCCursor(clrCurs);
- gCursID = cursID;
- gCursChange = TickCount();
- }
- }
-